<?php

namespace app\system\controller;


use app\system\service\MenuService;
use app\system\service\RoleMenuService;
use app\system\service\RolesService;
use think\Request;

class Roles
{
    protected $rolesService;
    protected $menuService;
    protected $roleMenuService;

    public function __construct(RolesService $rolesService, MenuService $menuService, RoleMenuService $roleMenuService)
    {
        $this->rolesService = $rolesService;
        $this->menuService = $menuService;
        $this->roleMenuService = $roleMenuService;
    }

    /**
     * 描述:获取角色列表
     * 参数:{}
     * 返回:
     * 作者:W
     */
    public function getRoleList(Request $request)
    {
        $rolesList = $this->rolesService->roleList($request);
        // 发送JSON响应
        return returnPageJson($rolesList);
    }

    /**
     * 描述:新增角色
     * 参数:{}
     * 返回:
     * 作者:W
     */
    public function addRole(Request $request)
    {
        return $this->rolesService->addRoles($request);
    }

    /**
     * 描述:更新角色
     * 参数:{}
     * 返回:
     * 作者:W
     */
    public function updateRole(Request $request)
    {
        return $this->rolesService->updateRole($request);
    }

    /**
     * 描述:删除角色
     * 参数:{}
     * 返回:
     * 作者:W
     */
    public function deleteRole(Request $request)
    {
        return $this->rolesService->deleteRole($request);
    }

    /**
     * 描述:根据用户ID查询角色
     * 参数:{}
     * 返回:
     * 作者:W
     */
    public function getRoleMenuIdsById(Request $request)
    {
        return $this->roleMenuService->getRoleMenuIdsById($request);
    }

    /**
     * 描述:获取角色菜单列表
     * 参数:{}
     * 返回:
     * 作者:W
     */
    public function getRoleMenuList(Request $request)
    {
        return $this->menuService->getRoleMenuList($request);
    }

    /**
     * 描述:保存角色菜单
     * 参数:{}
     * 返回:
     * 作者:W
     */
    public function saveRoleMenu(Request $request)
    {
        return $this->roleMenuService->saveRoleMenu($request);
    }

    /**
     * 描述:更新状态
     * 参数:{}
     * 返回:
     * 作者:W
     */
    public function updateStatus(Request $request)
    {
        return $this->rolesService->updateStatus($request);
    }

    /**
     * 描述:获取角色ID列表
     * 参数:{}
     * 返回:
     * 作者:W
     */
    public function listRoleIds(Request $request)
    {
        return $this->rolesService->listRoleIds($request);
    }
    public function listAllRole()
    {
        return $this->rolesService->getlistAllRole();
    }
}